<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
    <link rel="icon" href="./images/logo.ico" />
	<link rel="stylesheet" href="./css/common.css">
	<script src="js/sethtmlfontSize.js"></script>
	<title>登录</title>
	<style>
	     body{background:#f0f0f0;}
		.loginhead{width: 16rem;height: 9rem;position:relative;text-align: center;margin: 0 auto;margin-bottom: 1.5rem;}
        .loginhead .home{ width: 1rem;height: 1rem; position: absolute;right: 1rem;top: 1rem;}
        .loginhead .logo{width: 3.5rem;height: 3.5rem;display: block;margin: 0 auto;padding-top: 3rem;padding-bottom: 0.75rem;}
		.login{width: 16rem;margin: 0 auto;margin-bottom:1rem;}
        .height{width:12.25rem;height:.1rem;}
		.logindiv{width: 12.25rem;height: 2rem;margin: 0 auto;margin-bottom: .8rem;background: #fff; box-sizing: border-box;-webkit-box-sizing: border-box;padding-top: .4rem;position: relative;}
		.img{ display: inline-block;position: absolute;top: .4rem;width: 1.2rem;}
		.login-input{ width: 10rem;height: 1.2rem;position: absolute;left: 1.5rem;top: .4rem;outline: none;background: #fff;text-indent: .5rem;font-size: .6rem;}
		.login-submit{width: 12rem;height: 2rem; margin-left: 2rem;background: #37c7b7;margin-top: 0.4rem;color:#fff;font-size: .7rem;border-radius: 0.125rem;outline:none;border:none;-webkit-border-radius:0.125rem;-moz-border-radius:0.125rem;-ms-border-radius:0.125rem;-webkit-appearance:none;}
		.loginer{width: 12.25rem;text-align: center;margin: 0 auto;margin-top:15px;}
		.a1{float: left; text-decoration: none; color:#37c7b7; font-size: 0.25rem;}
		.a2{float: right; text-decoration: none; color:#37c7b7;font-size: 0.25rem;}
        .error {margin:0 auto; padding:.1rem .1rem;width:7rem;height:1.5rem;line-height:1.5rem; background: #333; opacity: 0.7; margin-top: 2rem;color:#fff;font-size: 0.5rem; text-align: center; display: none;border-radius:10px;-webkit-border-radius:10px;-moz-border-radius:10px;-ms-border-radius:10px;-webkit-appearance:none;}
        #zwl-back{font-size: 0.6rem;margin: 0 auto;width: 12rem;
        height: 2rem;text-align: right;line-height: 2rem;}
        #zwl-back a{color: #37c7b7;text-decoration: underline;}
	</style>
</head>
<body>
	<div class="loginhead">
<!--	    <img class="home" src="./images/myhome.png" alt="">-->
		<img class="logo" src="./images/logo.png" alt="">
		<h2>实地圈</h2>
	</div>
	<div class="login">
			<div class="logindiv">
				<img class="img" src="./images/tel.png" alt="">
				<input class="login-input user"  placeholder="输入账号" type="text" autocomplete="on" style="border:none;">
			</div>
			<div class="height"></div>
			<div class="logindiv">
				<img class="img" src="./images/pwd.png" alt="">
				<input class="login-input password"  placeholder="输入密码" type="password" autocomplete="on" style="border:none;">
			</div>
			<input class="login-submit" type="button"  value="登 &nbsp;&nbsp;录">
       <div id="zwl-back"><a href="index.html">返回首页</a></div>
        <br/>
			
	</div>
	
<!--
	<div class="loginer">
		<a class="a1" href="">找回密码</a> <a class="a2" href="">免费注册</a>
	</div>
-->
    <div class="error">
        账号或者密码错误！
    </div>
</body>
<script src="js/jquery-1.7.2.min.js"></script>
<script src="js/md5.js"></script>
<script>
   $(function(){
        //进入首页
        $(".loginhead img").on("click",function(){
             location.href="./index.html";
        });
        var url=SYS_GLOBAL_CONFIG.reqUrl,
        async=true,
        type="post";
        var requestData="";
        function getData(url,datas,call_func,async,type){
            console.log("qingqiucanshu:"+datas);
            $.ajax({
                url:url,
                type:type,
                datatype:"json",
                async:async,
                contentType:"application/json",
                data:datas,
                success:function(data){
                    call_func(data);
                },
                error:function(){
                    console.log("失败-----------");
                }   
            });        
        }
         function handdle_func1(data){
            console.log(data);
            var haslogin;
            var userId;
            var user=data.data.user;
            var id=user.userId;
            var name=user.userName
            var img=""; if(user.imageFullPath==undefined||user.imageFullPath==""||user.imageFullPath==null){
                img="./images/default.jpg";
            }else{
                img=user.imageFullPath;    
            }
            if(data.msg=="登录成功"){
               if(window.localStorage){
                   locaLStorage="";
                   localStorage.a="123123123";
                   localStorage.haslogin=true;
                   localStorage.userId=id;
                   localStorage.userName=name;
                   localStorage.userImg=img;
               }else{
                   alert("请打开浏览器cookie功能");
                   console.log("不支持localStorage");
               }
               
               url = "./index.html";
               location.href = url;
            }else{
               $(".error").fadeIn(1000);
               $(".error").fadeOut(500);
            }
        }  
        $(".login-submit").on("click",function(){
            phoneNO=$(".user").val();
            var password=hex_md5($(".password").val());
            console.info(phoneNO);
            console.info(password);
            var re = /^1\d{10}$/;
//            var reg = /^[0-9a-zA-Z]+$/;
            if(phoneNO.trim()==""){
                
                $(".error").html("账号不能为空！");
                $(".error").fadeIn(1000);
                $(".error").fadeOut(500);            
            }else{
                if(re.test(phoneNO)){
                    requestData=JSON.stringify({
                        "code":"login",
                        "version":"1.0",
                        "data":{
                            "phoneNO":phoneNO,
                            "password":password
                        }
                    });
                    console.log(requestData);
                    getData(url,requestData,handdle_func1,async,type);
                }else{
                    $(".error").html("账号密码格式不正确！");
                    $(".error").fadeIn(1000);
                    $(".error").fadeOut(500);
                }         
            }
        });
   });
</script>
</html>